package com.gmail.dmitryustimov.ms.observer.java8_lambda_outline;

public class Subscriber {

    String name;
    Writer writer;

    public Subscriber(Writer writer, final String name) {
        this.name = name;
        this.writer = writer;
        writer.bookEventPublisher.subscribe(processBook);
        writer.articleEventPublisher.subscribe(processArticle);
    }

    SubscribeAction<Book> processBook = (Book book) -> {
        System.out.println(name + " is processing: " + book);
    };

    SubscribeAction<Article> processArticle = (Article article) -> {
        System.out.println(name + " is processing: " + article);
    };
}
